package ensib.sti.ssu.activities;

import ensib.sti.ssu.R;
import android.annotation.SuppressLint;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.PreferenceActivity;
import android.widget.Toast;

public class Preference extends PreferenceActivity implements OnSharedPreferenceChangeListener  {
 
public static final String KEY_LIST_PREFERENCE = "BLOC_NOTE_PREFERENCE";
 
	 private ListPreference mListPreference;
	@SuppressWarnings("deprecation")
	@Override
	protected void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		addPreferencesFromResource(R.xml.preferences);
		 mListPreference = (ListPreference)getPreferenceScreen().findPreference(KEY_LIST_PREFERENCE);
		   getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
	}
	 

    @SuppressWarnings("deprecation")
	@Override
    protected void onPause() {
        super.onPause();

                
        getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);    
    }
	@SuppressLint("ShowToast")
	@Override
	public void onSharedPreferenceChanged(SharedPreferences arg0, String key) {
		// TODO Auto-generated method stub
		if (key.equals(KEY_LIST_PREFERENCE)) {
			String pref=mListPreference.getValue() ;
			 
            mListPreference.setSummary(getResources().getString(R.string.message_choix_preerence_tri) +"["+ pref+"]"); 
            
        }
	}
}
